package com.lisp.clp.parent_first;

import java.net.URL;
import java.net.URLClassLoader;

import org.apache.commons.logging.LogFactory;

/**
 * commons-logging使用TCCL进行runtime discovery， 从而得出应该用log4j
 * 但实际初始化log4j时，又用了AppClassLoader，所以会抛出异常
 */
public class ParentFirstTestJCL2 
{
    public static void main( String[] args ) throws Exception
    {
        URLClassLoader childClassLoader = new URLClassLoader(
	        new URL[] {
	          new URL("file:lib/log4j-1.2.17.jar")
        });
        
        Thread.currentThread().setContextClassLoader(childClassLoader);
        
        LogFactory.getLog("logger.name.not.important.here");
    }
}
